
R version 4.1.2 (2021-11-01) -- "Bird Hippie"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(tidyverse)
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
✔ ggplot2 3.3.5     ✔ purrr   0.3.4
✔ tibble  3.1.2     ✔ dplyr   1.0.8
✔ tidyr   1.1.3     ✔ stringr 1.4.0
✔ readr   1.4.0     ✔ forcats 0.5.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
> 
> ###read in coded data
> # collected data from multiple journals using skin color measure
> coded_data<-read.csv("articles_skin_color.csv")
> 
> coded_data<-coded_data %>%
+   mutate(method_name = case_when(
+     method1 == 0 ~"No skin color measure",
+     method1 == 1 ~ "Self-Report: Likert Scale",
+     method1 == 2 ~ "Self-Report: Palette Scale",
+     method1 == 3 ~ "Interviewer-Report: Palette Scale/Other",
+     method1 == 4 ~ "Spectrometer Measure",
+     method1 == 5 ~ "Photo Elicitation: Asked to classify based on images",
+     method1 == 6 ~ "Qualitative Interviews: Respondent identifies skin color based on conversation"
+   ))
> 
> ## keep only ones that have a skin color measure
> skin_color_measure_only<-subset(coded_data, method1 != 0)
> skin_color_measure_only<-skin_color_measure_only %>%
+   mutate(simple_measure = case_when(
+     method1 == 1 ~ 1,
+     method1 == 2 ~ 1,
+     method1 == 3 ~1,
+     method1 == 4 ~ 4,
+     method1 == 5 ~ 5,
+     method1 == 6 ~ 6
+     
+   ))
> 
> skin_color_measure_only<-skin_color_measure_only %>%
+   mutate(method_name = case_when(
+     # simple_measure == 0 ~"No skin color measure",
+     simple_measure == 1 ~ "Likert/Color Palette Scale",
+     simple_measure == 2 ~ "Self-Report: Palette Scale",
+     simple_measure == 3 ~ "Interviewer-Report: Palette Scale/Other",
+     simple_measure == 4 ~ "Spectrometer Measure",
+     simple_measure == 5 ~ "Photo Elicitation: Asked to classify based on images",
+     simple_measure == 6 ~ "Qualitative Interviews: Respondent identifies skin color based on conversation"
+   ))
> 
> 
> #make summaries
> summary_skin_color<- skin_color_measure_only %>%
+   group_by( method_name) %>%
+   summarise( 
+     n = n(),
+     total = sum(n)) %>%
+   mutate(percent = round((n/sum(n)), digits = 2))
> 
> #make summaries by year
> summary_skin_color_year <- skin_color_measure_only %>%
+   group_by(Publication.Year, method_name) %>%
+   summarise( 
+     n = n(),
+     total = sum(n)) %>%
+   mutate(percent = round((n/sum(n)), digits = 2))
`summarise()` has grouped output by 'Publication.Year'. You can override using the `.groups` argument.
> 
> #Figure: Counts of Skin Color Measurement Methods by Publication Year
> counts_method_year_plot <- ggplot(summary_skin_color_year, 
+                                   aes(x = Publication.Year,
+                                       y = n,
+                                       fill = method_name)) +
+   geom_bar(position = "dodge", 
+            stat = "identity") + 
+   theme_minimal()+
+   xlab("")+ 
+   ylab("Counts")+
+   labs(title = "Counts of Skin Color Measurement Methods by Publication Year ",
+        subtitle = "Published Articles in Social Sciences") +
+   theme(plot.title = element_text(size=18, 
+                                   face = "bold"), 
+         plot.subtitle = element_text(size=12))+
+   labs(fill = "Skin Color Measure Type")
> 
> 
> #Figure: "Percent of Skin Color Measurement Methods" ####
> pct_color_methods <- ggplot(summary_skin_color,
+          aes(x = reorder(method_name, 
+                          -percent),
+              y = percent,
+              fill = method_name
+          )) + 
+   geom_bar(stat = "identity") +
+   theme_minimal() + 
+   xlab("") + 
+   ylab("Percent") + 
+   labs(title = "Percent of Skin Color Measurement Methods ", 
+        subtitle = "Published Articles in Social Sciences") + 
+   theme(plot.title = element_text(size = 18, 
+                                   face = "bold"),
+         axis.text.x = element_blank(),
+         plot.subtitle = element_text(size = 12)) +
+   labs(fill = "Skin Color Measure Type") + 
+   geom_text(aes(label = percent), 
+             vjust = -0.25)
> 
> # Save plots
> plot_height <- 5
> plot_width <- 9
> ggsave("counts_method_year_plot.pdf",
+        counts_method_year_plot,
+        height = plot_height,
+        width = plot_width,
+        units = "in")
> ggsave("pct_color_methods.pdf",
+        pct_color_methods, 
+        height = plot_height,
+        width = plot_width,
+        units = "in")
> 
> 
> 
> 
> 
> 
> 
> proc.time()
   user  system elapsed 
  1.649   0.270   4.081 
